﻿Imports System
Imports System.ComponentModel
Imports System.Reflection
Imports System.Workflow.ComponentModel

Namespace System.Workflow.ComponentModel.Serialization
    Friend Class ModifyActivitiesPropertyDescriptor
        Inherits PropertyDescriptor
        ' Methods
        Public Sub New(ByVal propInfo As PropertyInfo)
            MyBase.New("CanModifyActivities", New Attribute(0  - 1) {})
            Me.propInfo = propInfo
        End Sub

        Public Overrides Function CanResetValue(ByVal component As Object) As Boolean
            Throw New NotImplementedException
        End Function

        Public Overrides Function GetValue(ByVal component As Object) As Object
            Return Me.propInfo.GetValue(component, Nothing)
        End Function

        Public Overrides Sub ResetValue(ByVal component As Object)
            Throw New NotImplementedException
        End Sub

        Public Overrides Sub SetValue(ByVal component As Object, ByVal value As Object)
            Me.propInfo.SetValue(component, True, Nothing)
            If TypeOf component Is CompositeActivity Then
                [TryCast](component,CompositeActivity).SetValue(Activity.CustomActivityProperty, False)
            End If
        End Sub

        Public Overrides Function ShouldSerializeValue(ByVal component As Object) As Boolean
            Return False
        End Function


        ' Properties
        Public Overrides ReadOnly Property ComponentType As Type
            Get
                Return GetType(CompositeActivity)
            End Get
        End Property

        Public Overrides ReadOnly Property IsReadOnly As Boolean
            Get
                Return False
            End Get
        End Property

        Public Overrides ReadOnly Property PropertyType As Type
            Get
                Return GetType(Boolean)
            End Get
        End Property


        ' Fields
        Private propInfo As PropertyInfo
    End Class
End Namespace

